package com.woniuxy.sort.core.controller;


import com.woniuxy.common.CommonResult;
import com.woniuxy.sort.core.mapper.YhServeMapper;
import com.woniuxy.sort.core.model.YhServe;
import com.woniuxy.sort.core.service.YhMaintainmenuService;
import com.woniuxy.sort.core.service.YhServeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author woniuxy
 * @since 2021-06-29
 */
@RestController
@RequestMapping("/yhServe")
@Api(tags = "养护二级菜单")
public class YhServeController {

    @Resource
    private YhServeMapper yhServeMapper;

    @Resource
    private YhServeService yhServeService;

    /**
     * Description : 养护二级菜单  <br/>
     * ChangeLog : 1. 创建 (2021/7/2 11:52 );
     *
     * @return com.woniuxy.common.CommonResult
    */
    @ApiOperation("养护二级菜单全部查询")
    @GetMapping("selectAll")
    public CommonResult selectAll(){
        List<YhServe> yhServes = this.yhServeService.list();
        if(yhServes == null){
            CommonResult.fail("查询养护二级菜单失败");
        }
        return CommonResult.success(yhServes);
    }


    /**
     * Description : 养护二级菜单根据id单个查询  <br/>
     * ChangeLog : 1. 创建 (2021/7/2 11:57 [Hello Mr. Guo]);
     * @param id
     * @return com.woniuxy.common.CommonResult
    */
    @ApiOperation("养护二级菜单根据id单个查询")
    @GetMapping("selectOne/{serveName}")
    public CommonResult selectOne(@PathVariable("serveName") String serveName){
        List<YhServe> yhServe = this.yhServeMapper.selectByName(serveName);
        System.out.println(yhServe);
        return CommonResult.success(yhServe);
    }

}

